<?php
session_start();
$title="แสดงรายการผู้ใช้ทั้งหมด";
include ('header-admin.php');

$userID=$_SESSION["HBD_USER"];
$countTopic=0;
if($userID == 1){
?>
<script language="javascript">
	function ConfirmChoice(id){
	answer = confirm("คุณแน่ใจว่าจะลบ ?")
		if (answer !=0)
			location = "doDeleteUser.php?userlist_id=" + id;
	}
</script>
<?}?>
<div id="center-block" class="main-content">
<img src="img/register.png"/ id="img-block-content">
<div id="content-title-right">
		<h2 class="caption-header">แสดงรายการผู้ใช้ทั้งหมด</h2>
		<span class="caption">แสดงรายการผู้ใช้ทั้งหมด เพื่อจัดการผู้ใช้</span>
		<span class="right-button">
		   <!--
<form name="jump" method="GET" action="#">
		   			<input type="text" id="search_cutomer" name="search_cutomer" value="" size="15"/>
		   			<input type="submit" value="ค้นหา" />
		   </form>
-->
				</span>

	</div>

	<hr>
	<table summary="webboard about Datastrucutre learning" id="table">
		<thead>
		<tr class="odd">
			<th scope="col" abbr="reserv_id">ID</th>
			<th scope="col" abbr="reserv_begin">Username</th>	
			<th scope="col" abbr="reserv_end">ชื่อ</th>
			<th scope="col" abbr="reserv_end">นามสกุล</th>
			<th scope="col" abbr="room_id">กลุ่มผู้ใช้</th>
			<th scope="col" abbr="customer_name">จัดการ</th>
		</tr>	
		</thead>
		<tbody>
		<?
	$sql="SELECT userlist_id,userlist_username,userlist_name,userlist_surname,group_name FROM `userlist`,`group` WHERE userlist.group_id=group.group_id ORDER BY userlist_id ASC";
	$result = mysql_query($sql);
	while ($rs = mysql_fetch_array($result)){
		$countTopic++;
		if($countTopic%2==0)
			echo '<tr class="odd">';
		else
			echo '<tr class="even">';
		echo '<td class="customer">' . $rs['userlist_id'] . '</a>';
		//$rs[ReplyCount]--;
		echo '</td>';
		echo '<td class="customer">' . $rs['userlist_username'] . '</td>';
		echo '<td class="customer">' . $rs['userlist_name'] . '</td>';
		echo '<td class="customer">' . $rs['userlist_surname'] . '</td>';
		echo '<td class="customer">' . $rs['group_name'] . '</td>';
		echo '<td><a href="editUser.php?userlist_id=' . $rs['userlist_id'] . '"><img src="img/icon_edit.png" /></a>&nbsp;<a href="#" onclick="ConfirmChoice(\'' . $rs['userlist_id'] . '\'); return false;"><img src="img/icon_delete.png" /></a>';
	}		
	?>
		</tbody>

	</table>
	</div>

<?
include ('footer.php');
?>